package com.huajx.armp.htxny.adapter;

import com.huajx.armp.htxny.handler.*;
import com.huajx.core.handler.HandlerAdapter;
import com.huajx.core.handler.ServerHandlerFactory;

/**
 * @program: di-parent
 * @description:
 * @author: lisa 叶新华
 * @create: 2020-03-25 15:29
 */
public class HtxnyHandlerAdapter extends ServerHandlerFactory {

    @Override
    public HandlerAdapter getHandler(Object message) {
        if (message instanceof byte[]) {
            byte[] bytes = (byte[]) message;
            byte command = bytes[2];
            switch (command) {
                case 0x01:
                    return new CarLoginHandler();
                case 0x02:
                    return new DataReportHandler();
                case 0x03:
                    return new DataReportAgainHandler();
                case 0x04:
                    return new CarLogoutHandler();
                case 0x05:
                    return new ServerLoginHandler();
                case 0x06:
                    return new ServerLogoutHandler();
            }
        }
        return null;
    }
}
